/*
 * AbsorptionCounter.cc
 *
 *  Created on: 08.05.2011
 *      Author: ed
 */

#include "AbsorptionCounter.hh"
#include "PrimariesGenerator.hh"
#include "G4VProcess.hh"
#include "G4TrackStatus.hh"
AbsorptionCounter::AbsorptionCounter(G4String name):G4VSensitiveDetector(name){}

AbsorptionCounter::~AbsorptionCounter(){}
void AbsorptionCounter::Initialize(G4HCofThisEvent*)
{
	ppe = PrimariesGenerator::GetNParticlesPerEvent();
	this->wallsAbsorptionCount = 0;
	this->aerogelAbsorptionCount = 0;
}
void AbsorptionCounter::EndOfEvent(G4HCofThisEvent*)
{
	G4cout<<"walls absorption count: "<<wallsAbsorptionCount<<",aerogel: "<<aerogelAbsorptionCount<<G4endl;
}
G4bool AbsorptionCounter::ProcessHits(G4Step*aStep,G4TouchableHistory*)
{
	//G4cout<<aStep->GetTrack()->GetTrackStatus()<< " last in voume"<<G4endl;
	if(aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()=="OpAbsorption")
		aerogelAbsorptionCount++;
	else if(aStep->GetTrack()->GetTrackStatus()!=fAlive)
		wallsAbsorptionCount++;
	return true;
}
